# Build context: repository root (Ninja Nexus/)
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY platform/contracts/Nexus.Contracts/Nexus.Contracts.csproj platform/contracts/Nexus.Contracts/
COPY source/nexus-identity/NexusIdentity.Api/NexusIdentity.Api.csproj source/nexus-identity/NexusIdentity.Api/
RUN dotnet restore source/nexus-identity/NexusIdentity.Api/NexusIdentity.Api.csproj
COPY platform/contracts/Nexus.Contracts/ platform/contracts/Nexus.Contracts/
COPY source/nexus-identity/NexusIdentity.Api/ source/nexus-identity/NexusIdentity.Api/
RUN dotnet publish source/nexus-identity/NexusIdentity.Api/NexusIdentity.Api.csproj \
    -c Release -o /app/publish --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
COPY --from=build /app/publish .
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
  CMD wget -qO- http://127.0.0.1:8080/health || exit 1
ENTRYPOINT ["dotnet", "NexusIdentity.Api.dll"]
